package com.bootdo.order.controller;

import com.bootdo.common.controller.BaseController;
import com.bootdo.common.utils.PageUtils;
import com.bootdo.common.utils.Query;
import com.bootdo.common.utils.R;
import com.bootdo.oa.domain.NotifyDO;
import com.bootdo.order.domain.OrderDo;
import com.bootdo.order.domain.Product;
import com.bootdo.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/order/order")
public class OrderController extends BaseController {

    @Autowired
    private OrderService orderService;

    @RequestMapping("/orderList")
    public String orderList(){
        return "order/order/order";
    }

    @RequestMapping("/list")
    @ResponseBody
    public PageUtils List(@RequestParam Map<String, Object> params){
        // 查询列表数据
        Query query = new Query(params);
        List<OrderDo> orderDoList = orderService.list(query);
        int total = orderService.count(query);
        PageUtils pageUtils = new PageUtils(orderDoList, total);
        return pageUtils;
    }

    @RequestMapping("/add")
    public String add(){
        return "order/order/add";
    }

    @RequestMapping("/save")
    @ResponseBody
    public R save(OrderDo orderDo){
        /*if (orderService.save(orderDo) > 0) {
            return R.ok();
        }*/
        List<Product> productList = orderDo.getProductList();
        return R.error();
    }

    @RequestMapping("/lll")
    public String getAllOrderList(){
        orderService.getAllOrderList();
        return null;
    }

}
